import 'package:flutter/cupertino.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Util/PageUtil.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyDialog.dart';
import 'package:imember/Widget/MyInput.dart';
import 'package:imember/Widget/MyPage.dart';

import 'CashExpend_AmountConfirm_Save.dart';

class CashExpend_Amount extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _CashExpend_Amount();
  }
}

class _CashExpend_Amount extends State {
  nextStepClick() {
    PageUtil().open(context, CashExpend_AmountConfirm_Save());
  }

  @override
  Widget build(BuildContext context) {
    return MyPage(
        Container(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Container(height: 12),
              Input("目前現金櫃金額", enable: false),
              Input("現金留存金額", hint: "請輸入金額，系統會自動算出匯出金額"),
              Input("現金匯出金額", enable: false),
              Expanded(child: Container()),
              OrangeBtn("下一步 >", width: 94, height: 32, margin: EdgeInsets.fromLTRB(0, 0, 60, 44), onTap: nextStepClick)
            ],
          ),
        ),
        title: "現金匯出");
  }
}

class Input extends StatelessWidget {
  String title;
  TextEditingController? controller;
  bool? enable;
  Color? bgColor;
  String? hint;

  Input(this.title, {this.controller, this.enable, this.hint, this.bgColor});

  @override
  Widget build(BuildContext context) {
    enable = enable ?? true;
    return Container(
        padding: EdgeInsets.fromLTRB(80, 13, 80, 0),
        alignment: Alignment.center,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(width: 180, child: Text(title, style: TextStyle(fontSize: 17, color: MyColor.C70))),
            Expanded(
                child: Container(
                    height: 36,
                    width: 300,
                    padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                    decoration: Global.getBoxBg(18, bgColor ?? MyColor.E7),
                    alignment: Alignment.centerLeft,
                    child: enable!
                        ? NormalInput(fontSize: 18, controller: controller, hintText: hint)
                        : Text("0", style: TextStyle(fontSize: 18))))
          ],
        ));
  }
}
